﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MS.Basic.ReadAPI.Application.Commons.Account;
using MS.Basic.ReadAPI.Application.Commons.BaoJianRead;
using MS.Basic.ReadAPI.Application.Commons.QiYeRead;
using MS.Basic.ReadAPI.Application.Commons.ShangPinRead;
using MS.Basic.ReadAPI.Application.Commons.YangZhiRead;
using MS.Common.Service;

namespace MS.Basic.ReadAPI.Controllers
{
    /// <summary>
    /// 读API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AccountController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"> 中介者</param>
        public AccountController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="name"> 用户名</param>
        /// <param name="pwd"> 密码</param>
        /// <returns>返回符合条件数据</returns>
        [HttpGet]
        public async Task<APIResult> GetLogin(string name,string pwd)
        {
            AccountQueryRequestModel model = new AccountQueryRequestModel();
            model.name=name;
            model.pwd=pwd;
            return await mediator.Send(model);
        }

        /// <summary>
        /// 商品显示
        /// </summary>
        /// <returns> 返回符合条件数据</returns>
        [HttpGet]
        public async Task<APIResult> ShangPinShow()
        {
            ShangPinQueryRequestModel model = new ShangPinQueryRequestModel();
            return await mediator.Send(model);
        }

        /// <summary>
        /// 养殖显示
        /// </summary>
        /// <returns> 返回符合条件数据</returns>
        [HttpGet]
        public async Task<APIResult> YangZhiShow()
        {
            YangZhiQueryRequestModel model = new YangZhiQueryRequestModel();
            return await mediator.Send(model);
        }

        /// <summary>
        /// 保健显示
        /// </summary>
        /// <returns> 返回符合条件数据</returns>
        [HttpGet]
        public async Task<APIResult> BaoJianShow()
        {
            BaoJianQueryRequestModel model = new BaoJianQueryRequestModel();
            return await mediator.Send(model);
        }

        /// <summary>
        /// 企业显示
        /// </summary>
        /// <returns> 返回符合条件数据</returns>
        [HttpGet]
        public async Task<APIResult> QiYeShow()
        {
            QiYeQueryRequestModel model = new QiYeQueryRequestModel();
            return await mediator.Send(model);
        }
    }
}
